#ifndef _SHADOW_FILESYSTEM_NAME_SVR_BUSINESS_H_
#define _SHADOW_FILESYSTEM_NAME_SVR_BUSINESS_H_

#include <string>
#include <set>

#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>

#include "MysqlConnPool.h"
#include "sfs_common.h"

#define FILE_HASH_LEVEL 2
#define NUM_DIR_PER_HASH_LEVEL 256

using std::string;
using std::set;

class NameSvrBusiness {
		public:
				NameSvrBusiness();
				int init(const char * mysqld_host, const int mysqld_port, const char * mysqld_user, \
								const char * mysqld_passwd, const int mysql_conn_pool_num);
				virtual ~NameSvrBusiness();

				int gen_file_name(string & file_name);
				int create_file(const SFS_FILE_METADATA & file_metadata);
				int get_file_metadata(SFS_FILE_METADATA & file_metadata, const char * file_path);
				int mod_file_metadata(const SFS_FILE_METADATA & file_metadata, const set<string> & need_mod_fields, \
								const char * file_path);
				int del_file(const char * file_path);
				int lock_file(const char * file_path);
				int unlock_file(const char * file_path);

		private:
				 log4cxx::LoggerPtr _logger;
				 MysqlConnPool _mysql_conn_pool;

};

#endif
